<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="layui/css/layui.css">
    <style type="text/css">
        #bg {
             position: fixed;
             left: 0;
             top: 0;
             height: 50%;
             width: 100%;
             z-index: -1;
             background-color: pink;
         }

        .container {
            width: 600px;
            height: 620px;
            min-height: 320px;
            max-height: 320px;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
            padding: 20px;
            z-index: 130;
            border-radius: 8px;
            background-color: #fff;
            box-shadow: 0 3px 18px rgba(100, 0, 0, .5);
            font-size: 16px;
        }

        .layui-input {
            border-radius: 5px;
            width: 300px;
            height: 40px;
            font-size: 15px;
        }

        .layui-input {
            border-color: gray;
        }

        .layui-form-item {
            margin-left: 50px;
            margin-top: -8px;
        }

        #logoid1 {
            font-family: 幼圆;
            margin-top: 15px;
            padding-left: 200px;
            padding-bottom: 15px;
            color: black;
        }

        #logoid {
            margin-top: -15px;
            padding-left: 270px;
            padding-bottom: 15px;
            color: palevioletred;
            font-family: 幼圆;
        }

        .layui-btn {
            margin-left: 200px;
            border-radius: 5px;
            width: 80px;
            height: 40px;
            font-size: 15px;
        }

        .verity {
            width: 120px;
        }

        .font-set {
            font-size: 16px;
            text-decoration: none;
            margin-left: 370px;
            font-family: 幼圆;
        }

        a:hover {
            text-decoration: underline;
        }

    </style>
</head>
<body>
<div id="bg"></div>
<form class="layui-form">
    <div class="container">
        <h2 id="logoid1">医院住院管理系统</h2>
        <div class="layui-form-mid layui-word-aux">
            <h3 id="logoid">用户登录</h3>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-block">
                <input type="text" name="name" required lay-verify="required|account" placeholder="请输入用户名"
                       autocomplete="on" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required|password" placeholder="请输入密码"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">身份类型</label>
            <div class="layui-input-block">
                <input type="radio" name="typeId" value="1" title="管理员" checked="">
                <input type="radio" name="typeId" value="2" title="医生">
                <input type="radio" name="typeId" value="3" title="护士">
                <!--<input type="radio" name="name" value="患者" title="患者">-->
                <input type="radio" name="typeId" value="4" title="大厅管理员">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">登陆</button>
            </div>
        </div>
    </div>
</form>
<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-1.12.2.min.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            $.ajax({
                type: "post",
                url: "/user/login",
                data: data.field,
                dataType: "json",
                success: function (data) {
/*                    if (data.code == 0) {
                        alert("错误，请选择身份类型")
                    }*/
                    if (data.message != undefined) {
                        alert(data.message)
                    }
                    if (data.info == 1) {
                        window.location.href = "http://localhost:8080/admin/admin.html";
                    }
                    if (data.info == 2) {
                        window.location.href = "http://localhost:8080/doctor/doctor.html";
                    }
                    if (data.info == 3) {
                        window.location.href = "http://localhost:8080/nurse/nurse.html";
                    }
                    if (data.info == 4) {
                        window.location.href = "http://localhost:8080/serviceManager/index.html";
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
